
import axios from 'axios';

/**
 * 定时任务
 */
export class ScheduledTaskService {
    // 分页查询列表
    static findScheduledTasks (queryParams) {
        return axios({
            url: '/system/scheduledTask/ScheduledTask/findScheduledTasks',
            method: 'POST',
            data: queryParams
        });
    }

    //根据ID查询指定的定时任务
    static findScheduledTask (scheduledTaskId) {
        const query = {
            scheduledTaskId
        }
        return axios({
            url: '/system/scheduledTask/ScheduledTask/findScheduledTask',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的定时任务(包含外键名称)
    static findScheduledTaskForView (scheduledTaskId) {
        const query = {
            scheduledTaskId
        }
        return axios({
            url: '/system/scheduledTask/ScheduledTask/findScheduledTaskForView',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的定时任务(包含外键名称)
    static findScheduledTaskForEdit (scheduledTaskId) {
        const query = {
            scheduledTaskId
        }
        return axios({
            url: '/system/scheduledTask/ScheduledTask/findScheduledTaskForEdit',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的定时任务(只提取ID 和 Name)
    static findScheduledTasksWithIdNameById (scheduledTaskId) {
        const query = {
            scheduledTaskId
        }
        return axios({
            url: '/system/scheduledTask/ScheduledTask/findScheduledTasksWithIdNameById',
            method: 'POST',
            params: query,
        });
    }

    //根据名称查询定时任务集合(只提取ID 和 Name)
    static findScheduledTasksWithIdNameByName (scheduledTaskName) {
        const query = {
            scheduledTaskName
        }
        return axios({
            url: '/system/scheduledTask/ScheduledTask/findScheduledTasksWithIdNameByName',
            method: 'POST',
            params: query,
        });
    }

    //新增保存定时任务
    static saveScheduledTask (scheduledTask) {
        const query = {}
        return axios({
            url: '/system/scheduledTask/ScheduledTask/saveScheduledTask',
            method: 'POST',
            params: query,
            data: scheduledTask
        });
    }

    //修改保存定时任务
    static updateScheduledTask (scheduledTask) {
        const query = {}
        return axios({
            url: '/system/scheduledTask/ScheduledTask/updateScheduledTask',
            method: 'POST',
            params: query,
            data: scheduledTask
        });
    }

    //根据ID查询指定的定时任务(只提取ID 和 Name)
    static deleteScheduledTask (jobName,groupName) {
        const query = {
            jobName,groupName
        }
        return axios({
            url: '/system/scheduledTask/ScheduledTask/deleteScheduledTask',
            method: 'POST',
            params: query,
        });
    }

  static findServices() {
    const query = {

    }
    return axios({
      url: '/system/scheduledTask/ScheduledTask/findServices',
      method: 'POST',
      params: query,
    });
  }

  static pauseJob(jobName, groupName) {
    const query = {
      jobName,groupName
    }
    return axios({
      url: '/system/scheduledTask/ScheduledTask/pauseJob',
      method: 'POST',
      params: query,
    });
  }

  static resumeJob(jobName, groupName) {
    const query = {
      jobName,groupName
    }
    return axios({
      url: '/system/scheduledTask/ScheduledTask/resumeJob',
      method: 'POST',
      params: query,
    });
  }

  static resumeAllJobs() {
    const query = {
    }
    return axios({
      url: '/system/scheduledTask/ScheduledTask/resumeAllJobs',
      method: 'POST',
      params: query,
    });
  }

  static pauseAllJobs() {
    const query = {
    }
    return axios({
      url: '/system/scheduledTask/ScheduledTask/pauseAllJobs',
      method: 'POST',
      params: query,
    });
  }
}
